/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gen2phen.labs.actions;

import com.aetrion.flickr.photos.PhotoList;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;
import org.gen2phen.labs.services.Flicks;

/**
 *
 * @author pedrolopes
 *
 * GEN2PHEN Semantic Web Labs: Knowledge Mashup
 *
 */
@UrlBinding("/flickr/{$event}/{query}")
public class FlickrActionBean implements ActionBean {

    private ActionBeanContext context;
    private String query;   // Flickr Search query
    private PhotoList photos = new PhotoList();

    public PhotoList getPhotos() {
        return photos;
    }

    public void setPhotos(PhotoList photos) {
        this.photos = photos;
    }

    public String getQuery() {
        return query;
    }

    public void setQuery(String query) {
        this.query = query;
    }

    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    public ActionBeanContext getContext() {
        return context;
    }

    /**
     * Access the Flicks class, loading results for the given search query.
     * Handles the "search" event and all other non-specified events.
     *
     * @return a text file containing Flickr images information that will be processed by the client-side JavaScript
     */
    @DefaultHandler
    public Resolution search() {
        return new StreamingResolution("text", Flicks.get(query));
    }
}
